﻿//------------------------------------------------------------------------------
// 创建标识: Copyright (C) 2008 Socansoft.com 版权所有
// 创建描述: SocanCode代码生成器自动创建于 2008-9-10 14:34:57
//
// 功能描述: 
//
// 修改标识: 
// 修改描述: 
//------------------------------------------------------------------------------

using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;

using DBUtility;
using System.Collections;
using System.Collections.Generic;


/// <summary>
/// 数据访问类 V_CUSTOMER
/// </summary>
public class V_CUSTOMER
{
    public V_CUSTOMER()
    { }

    #region  成员方法
    /// <summary>
    /// 增加一条数据
    /// </summary>
    public string Add(Model.V_CUSTOMER model)
    {
        int rowsAffected;
        SqlParameter[] parameters = {
                    new SqlParameter("@DM", SqlDbType.VarChar,20),
                    new SqlParameter("@GKMC", SqlDbType.VarChar,50),
                    new SqlParameter("@SEX", SqlDbType.VarChar,2),
                    new SqlParameter("@SR", SqlDbType.DateTime),
                    new SqlParameter("@BM", SqlDbType.VarChar,20),
                    new SqlParameter("@KITHMC", SqlDbType.VarChar,20),
                    new SqlParameter("@KITHSEX", SqlDbType.VarChar,2),
                    new SqlParameter("@QYDM", SqlDbType.VarChar,6),
                    new SqlParameter("@QDDM", SqlDbType.VarChar,6),
                    new SqlParameter("@CKDM", SqlDbType.VarChar,6),
                    new SqlParameter("@JDRQ", SqlDbType.DateTime),
                    new SqlParameter("@XGRQ", SqlDbType.DateTime),
                    new SqlParameter("@FKBJ", SqlDbType.Char,1),
                    new SqlParameter("@TKBJ", SqlDbType.Char,1),
                    new SqlParameter("@XFJE", SqlDbType.Decimal),
                    new SqlParameter("@XFSL", SqlDbType.Int),
                    new SqlParameter("@DQJF", SqlDbType.Int),
                    new SqlParameter("@DZ", SqlDbType.VarChar,200),
                    new SqlParameter("@YB", SqlDbType.VarChar,20),
                    new SqlParameter("@SJ", SqlDbType.VarChar,20),
                    new SqlParameter("@DH", SqlDbType.VarChar,20),
                    new SqlParameter("@CZ", SqlDbType.VarChar,20),
                    new SqlParameter("@EMAIL", SqlDbType.VarChar,50),
                    new SqlParameter("@BZ", SqlDbType.VarChar,100),
                    new SqlParameter("@SZGG", SqlDbType.VarChar,6),
                    new SqlParameter("@XZGG", SqlDbType.VarChar,6),
                    new SqlParameter("@COUNTRY", SqlDbType.VarChar,6),
                    new SqlParameter("@DISTRICT", SqlDbType.VarChar,6),
                    new SqlParameter("@CITY", SqlDbType.VarChar,6),
                    new SqlParameter("@EDUCATION", SqlDbType.VarChar,6),
                    new SqlParameter("@OCCUPATION", SqlDbType.VarChar,6),
                    new SqlParameter("@MARRY", SqlDbType.VarChar,6),
                    new SqlParameter("@EARNING", SqlDbType.VarChar,6),
                    new SqlParameter("@WORTH", SqlDbType.VarChar,6),
                    new SqlParameter("@DUDS", SqlDbType.VarChar,6),
                    new SqlParameter("@KNOWS", SqlDbType.VarChar,6),
                    new SqlParameter("@FJSX1", SqlDbType.VarChar,6),
                    new SqlParameter("@FJSX2", SqlDbType.VarChar,6),
                    new SqlParameter("@FJSX3", SqlDbType.VarChar,6),
                    new SqlParameter("@FJSX4", SqlDbType.VarChar,6),
                    new SqlParameter("@FJSX5", SqlDbType.VarChar,6),
                    new SqlParameter("@FJSX6", SqlDbType.VarChar,6),
                    new SqlParameter("@BYZD1", SqlDbType.Char,1),
                    new SqlParameter("@BYZD2", SqlDbType.Char,1),
                    new SqlParameter("@BYZD3", SqlDbType.VarChar,20),
                    new SqlParameter("@BYZD4", SqlDbType.VarChar,20),
                    new SqlParameter("@BYZD5", SqlDbType.VarChar,50),
                    new SqlParameter("@BYZD6", SqlDbType.VarChar,150),
                    new SqlParameter("@BYZD7", SqlDbType.VarChar,150),
                    new SqlParameter("@BYZD8", SqlDbType.Int),
                    new SqlParameter("@BYZD9", SqlDbType.Int),
                    new SqlParameter("@BYZD10", SqlDbType.Int),
                    new SqlParameter("@BYZD11", SqlDbType.Float),
                    new SqlParameter("@BYZD12", SqlDbType.Float),
                    new SqlParameter("@BYZD13", SqlDbType.Float),
                    new SqlParameter("@BYZD14", SqlDbType.DateTime),
                    new SqlParameter("@BYZD15", SqlDbType.DateTime),
                    new SqlParameter("@AGE", SqlDbType.Int),
                    new SqlParameter("@VERSION", SqlDbType.VarChar,10)
            };
        parameters[0].Value = model.DM;

        if (model.GKMC != null)
            parameters[1].Value = model.GKMC;
        else
            parameters[1].Value = DBNull.Value;


        if (model.SEX != null)
            parameters[2].Value = model.SEX;
        else
            parameters[2].Value = DBNull.Value;


        if (model.SR != DateTime.MinValue)
            parameters[3].Value = model.SR;
        else
            parameters[3].Value = DBNull.Value;


        if (model.BM != null)
            parameters[4].Value = model.BM;
        else
            parameters[4].Value = DBNull.Value;


        if (model.KITHMC != null)
            parameters[5].Value = model.KITHMC;
        else
            parameters[5].Value = DBNull.Value;


        if (model.KITHSEX != null)
            parameters[6].Value = model.KITHSEX;
        else
            parameters[6].Value = DBNull.Value;


        if (model.QYDM != null)
            parameters[7].Value = model.QYDM;
        else
            parameters[7].Value = DBNull.Value;


        if (model.QDDM != null)
            parameters[8].Value = model.QDDM;
        else
            parameters[8].Value = DBNull.Value;


        if (model.CKDM != null)
            parameters[9].Value = model.CKDM;
        else
            parameters[9].Value = DBNull.Value;


        if (model.JDRQ != DateTime.MinValue)
            parameters[10].Value = model.JDRQ;
        else
            parameters[10].Value = DBNull.Value;


        if (model.XGRQ != DateTime.MinValue)
            parameters[11].Value = model.XGRQ;
        else
            parameters[11].Value = DBNull.Value;


        if (model.FKBJ != null)
            parameters[12].Value = model.FKBJ;
        else
            parameters[12].Value = DBNull.Value;


        if (model.TKBJ != null)
            parameters[13].Value = model.TKBJ;
        else
            parameters[13].Value = DBNull.Value;

        parameters[14].Value = model.XFJE;
        parameters[15].Value = model.XFSL;
        parameters[16].Value = model.DQJF;

        if (model.DZ != null)
            parameters[17].Value = model.DZ;
        else
            parameters[17].Value = DBNull.Value;


        if (model.YB != null)
            parameters[18].Value = model.YB;
        else
            parameters[18].Value = DBNull.Value;


        if (model.SJ != null)
            parameters[19].Value = model.SJ;
        else
            parameters[19].Value = DBNull.Value;


        if (model.DH != null)
            parameters[20].Value = model.DH;
        else
            parameters[20].Value = DBNull.Value;


        if (model.CZ != null)
            parameters[21].Value = model.CZ;
        else
            parameters[21].Value = DBNull.Value;


        if (model.EMAIL != null)
            parameters[22].Value = model.EMAIL;
        else
            parameters[22].Value = DBNull.Value;


        if (model.BZ != null)
            parameters[23].Value = model.BZ;
        else
            parameters[23].Value = DBNull.Value;


        if (model.SZGG != null)
            parameters[24].Value = model.SZGG;
        else
            parameters[24].Value = DBNull.Value;


        if (model.XZGG != null)
            parameters[25].Value = model.XZGG;
        else
            parameters[25].Value = DBNull.Value;


        if (model.COUNTRY != null)
            parameters[26].Value = model.COUNTRY;
        else
            parameters[26].Value = DBNull.Value;


        if (model.DISTRICT != null)
            parameters[27].Value = model.DISTRICT;
        else
            parameters[27].Value = DBNull.Value;


        if (model.CITY != null)
            parameters[28].Value = model.CITY;
        else
            parameters[28].Value = DBNull.Value;


        if (model.EDUCATION != null)
            parameters[29].Value = model.EDUCATION;
        else
            parameters[29].Value = DBNull.Value;


        if (model.OCCUPATION != null)
            parameters[30].Value = model.OCCUPATION;
        else
            parameters[30].Value = DBNull.Value;


        if (model.MARRY != null)
            parameters[31].Value = model.MARRY;
        else
            parameters[31].Value = DBNull.Value;


        if (model.EARNING != null)
            parameters[32].Value = model.EARNING;
        else
            parameters[32].Value = DBNull.Value;


        if (model.WORTH != null)
            parameters[33].Value = model.WORTH;
        else
            parameters[33].Value = DBNull.Value;


        if (model.DUDS != null)
            parameters[34].Value = model.DUDS;
        else
            parameters[34].Value = DBNull.Value;


        if (model.KNOWS != null)
            parameters[35].Value = model.KNOWS;
        else
            parameters[35].Value = DBNull.Value;


        if (model.FJSX1 != null)
            parameters[36].Value = model.FJSX1;
        else
            parameters[36].Value = DBNull.Value;


        if (model.FJSX2 != null)
            parameters[37].Value = model.FJSX2;
        else
            parameters[37].Value = DBNull.Value;


        if (model.FJSX3 != null)
            parameters[38].Value = model.FJSX3;
        else
            parameters[38].Value = DBNull.Value;


        if (model.FJSX4 != null)
            parameters[39].Value = model.FJSX4;
        else
            parameters[39].Value = DBNull.Value;


        if (model.FJSX5 != null)
            parameters[40].Value = model.FJSX5;
        else
            parameters[40].Value = DBNull.Value;


        if (model.FJSX6 != null)
            parameters[41].Value = model.FJSX6;
        else
            parameters[41].Value = DBNull.Value;


        if (model.BYZD1 != null)
            parameters[42].Value = model.BYZD1;
        else
            parameters[42].Value = DBNull.Value;


        if (model.BYZD2 != null)
            parameters[43].Value = model.BYZD2;
        else
            parameters[43].Value = DBNull.Value;


        if (model.BYZD3 != null)
            parameters[44].Value = model.BYZD3;
        else
            parameters[44].Value = DBNull.Value;


        if (model.BYZD4 != null)
            parameters[45].Value = model.BYZD4;
        else
            parameters[45].Value = DBNull.Value;


        if (model.BYZD5 != null)
            parameters[46].Value = model.BYZD5;
        else
            parameters[46].Value = DBNull.Value;


        if (model.BYZD6 != null)
            parameters[47].Value = model.BYZD6;
        else
            parameters[47].Value = DBNull.Value;


        if (model.BYZD7 != null)
            parameters[48].Value = model.BYZD7;
        else
            parameters[48].Value = DBNull.Value;

        parameters[49].Value = model.BYZD8;
        parameters[50].Value = model.BYZD9;
        parameters[51].Value = model.BYZD10;
        parameters[52].Value = model.BYZD11;
        parameters[53].Value = model.BYZD12;
        parameters[54].Value = model.BYZD13;

        if (model.BYZD14 != DateTime.MinValue)
            parameters[55].Value = model.BYZD14;
        else
            parameters[55].Value = DBNull.Value;


        if (model.BYZD15 != DateTime.MinValue)
            parameters[56].Value = model.BYZD15;
        else
            parameters[56].Value = DBNull.Value;

        parameters[57].Value = model.AGE;

        if (model.VERSION != null)
            parameters[58].Value = model.VERSION;
        else
            parameters[58].Value = DBNull.Value;

        SqlHelper.RunProcedure(DB.WEBConnectionString, "sp_V_CUSTOMER_ADD", parameters, out rowsAffected);

        if (rowsAffected > 0)
            return model.DM;
        else
            return null;
    }

    /// <summary>
    /// 更新一条数据
    /// </summary>
    public bool Update(Model.V_CUSTOMER model)
    {
        int rowsAffected;
        SqlParameter[] parameters = {
                    new SqlParameter("@DM", SqlDbType.VarChar,20),
                    new SqlParameter("@GKMC", SqlDbType.VarChar,50),
                    new SqlParameter("@SEX", SqlDbType.VarChar,2),
                    new SqlParameter("@SR", SqlDbType.DateTime),
                    new SqlParameter("@BM", SqlDbType.VarChar,20),
                    new SqlParameter("@KITHMC", SqlDbType.VarChar,20),
                    new SqlParameter("@KITHSEX", SqlDbType.VarChar,2),
                    new SqlParameter("@QYDM", SqlDbType.VarChar,6),
                    new SqlParameter("@QDDM", SqlDbType.VarChar,6),
                    new SqlParameter("@CKDM", SqlDbType.VarChar,6),
                    new SqlParameter("@JDRQ", SqlDbType.DateTime),
                    new SqlParameter("@XGRQ", SqlDbType.DateTime),
                    new SqlParameter("@FKBJ", SqlDbType.Char,1),
                    new SqlParameter("@TKBJ", SqlDbType.Char,1),
                    new SqlParameter("@XFJE", SqlDbType.Decimal),
                    new SqlParameter("@XFSL", SqlDbType.Int),
                    new SqlParameter("@DQJF", SqlDbType.Int),
                    new SqlParameter("@DZ", SqlDbType.VarChar,200),
                    new SqlParameter("@YB", SqlDbType.VarChar,20),
                    new SqlParameter("@SJ", SqlDbType.VarChar,20),
                    new SqlParameter("@DH", SqlDbType.VarChar,20),
                    new SqlParameter("@CZ", SqlDbType.VarChar,20),
                    new SqlParameter("@EMAIL", SqlDbType.VarChar,50),
                    new SqlParameter("@BZ", SqlDbType.VarChar,100),
                    new SqlParameter("@SZGG", SqlDbType.VarChar,6),
                    new SqlParameter("@XZGG", SqlDbType.VarChar,6),
                    new SqlParameter("@COUNTRY", SqlDbType.VarChar,6),
                    new SqlParameter("@DISTRICT", SqlDbType.VarChar,6),
                    new SqlParameter("@CITY", SqlDbType.VarChar,6),
                    new SqlParameter("@EDUCATION", SqlDbType.VarChar,6),
                    new SqlParameter("@OCCUPATION", SqlDbType.VarChar,6),
                    new SqlParameter("@MARRY", SqlDbType.VarChar,6),
                    new SqlParameter("@EARNING", SqlDbType.VarChar,6),
                    new SqlParameter("@WORTH", SqlDbType.VarChar,6),
                    new SqlParameter("@DUDS", SqlDbType.VarChar,6),
                    new SqlParameter("@KNOWS", SqlDbType.VarChar,6),
                    new SqlParameter("@FJSX1", SqlDbType.VarChar,6),
                    new SqlParameter("@FJSX2", SqlDbType.VarChar,6),
                    new SqlParameter("@FJSX3", SqlDbType.VarChar,6),
                    new SqlParameter("@FJSX4", SqlDbType.VarChar,6),
                    new SqlParameter("@FJSX5", SqlDbType.VarChar,6),
                    new SqlParameter("@FJSX6", SqlDbType.VarChar,6),
                    new SqlParameter("@BYZD1", SqlDbType.Char,1),
                    new SqlParameter("@BYZD2", SqlDbType.Char,1),
                    new SqlParameter("@BYZD3", SqlDbType.VarChar,20),
                    new SqlParameter("@BYZD4", SqlDbType.VarChar,20),
                    new SqlParameter("@BYZD5", SqlDbType.VarChar,50),
                    new SqlParameter("@BYZD6", SqlDbType.VarChar,150),
                    new SqlParameter("@BYZD7", SqlDbType.VarChar,150),
                    new SqlParameter("@BYZD8", SqlDbType.Int),
                    new SqlParameter("@BYZD9", SqlDbType.Int),
                    new SqlParameter("@BYZD10", SqlDbType.Int),
                    new SqlParameter("@BYZD11", SqlDbType.Float),
                    new SqlParameter("@BYZD12", SqlDbType.Float),
                    new SqlParameter("@BYZD13", SqlDbType.Float),
                    new SqlParameter("@BYZD14", SqlDbType.DateTime),
                    new SqlParameter("@BYZD15", SqlDbType.DateTime),
                    new SqlParameter("@AGE", SqlDbType.Int),
                    new SqlParameter("@VERSION", SqlDbType.VarChar,10)
            };
        parameters[0].Value = model.DM;

        if (model.GKMC != null)
            parameters[1].Value = model.GKMC;
        else
            parameters[1].Value = DBNull.Value;


        if (model.SEX != null)
            parameters[2].Value = model.SEX;
        else
            parameters[2].Value = DBNull.Value;


        if (model.SR != DateTime.MinValue)
            parameters[3].Value = model.SR;
        else
            parameters[3].Value = DBNull.Value;


        if (model.BM != null)
            parameters[4].Value = model.BM;
        else
            parameters[4].Value = DBNull.Value;


        if (model.KITHMC != null)
            parameters[5].Value = model.KITHMC;
        else
            parameters[5].Value = DBNull.Value;


        if (model.KITHSEX != null)
            parameters[6].Value = model.KITHSEX;
        else
            parameters[6].Value = DBNull.Value;


        if (model.QYDM != null)
            parameters[7].Value = model.QYDM;
        else
            parameters[7].Value = DBNull.Value;


        if (model.QDDM != null)
            parameters[8].Value = model.QDDM;
        else
            parameters[8].Value = DBNull.Value;


        if (model.CKDM != null)
            parameters[9].Value = model.CKDM;
        else
            parameters[9].Value = DBNull.Value;


        if (model.JDRQ != DateTime.MinValue)
            parameters[10].Value = model.JDRQ;
        else
            parameters[10].Value = DBNull.Value;


        if (model.XGRQ != DateTime.MinValue)
            parameters[11].Value = model.XGRQ;
        else
            parameters[11].Value = DBNull.Value;


        if (model.FKBJ != null)
            parameters[12].Value = model.FKBJ;
        else
            parameters[12].Value = DBNull.Value;


        if (model.TKBJ != null)
            parameters[13].Value = model.TKBJ;
        else
            parameters[13].Value = DBNull.Value;

        parameters[14].Value = model.XFJE;
        parameters[15].Value = model.XFSL;
        parameters[16].Value = model.DQJF;

        if (model.DZ != null)
            parameters[17].Value = model.DZ;
        else
            parameters[17].Value = DBNull.Value;


        if (model.YB != null)
            parameters[18].Value = model.YB;
        else
            parameters[18].Value = DBNull.Value;


        if (model.SJ != null)
            parameters[19].Value = model.SJ;
        else
            parameters[19].Value = DBNull.Value;


        if (model.DH != null)
            parameters[20].Value = model.DH;
        else
            parameters[20].Value = DBNull.Value;


        if (model.CZ != null)
            parameters[21].Value = model.CZ;
        else
            parameters[21].Value = DBNull.Value;


        if (model.EMAIL != null)
            parameters[22].Value = model.EMAIL;
        else
            parameters[22].Value = DBNull.Value;


        if (model.BZ != null)
            parameters[23].Value = model.BZ;
        else
            parameters[23].Value = DBNull.Value;


        if (model.SZGG != null)
            parameters[24].Value = model.SZGG;
        else
            parameters[24].Value = DBNull.Value;


        if (model.XZGG != null)
            parameters[25].Value = model.XZGG;
        else
            parameters[25].Value = DBNull.Value;


        if (model.COUNTRY != null)
            parameters[26].Value = model.COUNTRY;
        else
            parameters[26].Value = DBNull.Value;


        if (model.DISTRICT != null)
            parameters[27].Value = model.DISTRICT;
        else
            parameters[27].Value = DBNull.Value;


        if (model.CITY != null)
            parameters[28].Value = model.CITY;
        else
            parameters[28].Value = DBNull.Value;


        if (model.EDUCATION != null)
            parameters[29].Value = model.EDUCATION;
        else
            parameters[29].Value = DBNull.Value;


        if (model.OCCUPATION != null)
            parameters[30].Value = model.OCCUPATION;
        else
            parameters[30].Value = DBNull.Value;


        if (model.MARRY != null)
            parameters[31].Value = model.MARRY;
        else
            parameters[31].Value = DBNull.Value;


        if (model.EARNING != null)
            parameters[32].Value = model.EARNING;
        else
            parameters[32].Value = DBNull.Value;


        if (model.WORTH != null)
            parameters[33].Value = model.WORTH;
        else
            parameters[33].Value = DBNull.Value;


        if (model.DUDS != null)
            parameters[34].Value = model.DUDS;
        else
            parameters[34].Value = DBNull.Value;


        if (model.KNOWS != null)
            parameters[35].Value = model.KNOWS;
        else
            parameters[35].Value = DBNull.Value;


        if (model.FJSX1 != null)
            parameters[36].Value = model.FJSX1;
        else
            parameters[36].Value = DBNull.Value;


        if (model.FJSX2 != null)
            parameters[37].Value = model.FJSX2;
        else
            parameters[37].Value = DBNull.Value;


        if (model.FJSX3 != null)
            parameters[38].Value = model.FJSX3;
        else
            parameters[38].Value = DBNull.Value;


        if (model.FJSX4 != null)
            parameters[39].Value = model.FJSX4;
        else
            parameters[39].Value = DBNull.Value;


        if (model.FJSX5 != null)
            parameters[40].Value = model.FJSX5;
        else
            parameters[40].Value = DBNull.Value;


        if (model.FJSX6 != null)
            parameters[41].Value = model.FJSX6;
        else
            parameters[41].Value = DBNull.Value;


        if (model.BYZD1 != null)
            parameters[42].Value = model.BYZD1;
        else
            parameters[42].Value = DBNull.Value;


        if (model.BYZD2 != null)
            parameters[43].Value = model.BYZD2;
        else
            parameters[43].Value = DBNull.Value;


        if (model.BYZD3 != null)
            parameters[44].Value = model.BYZD3;
        else
            parameters[44].Value = DBNull.Value;


        if (model.BYZD4 != null)
            parameters[45].Value = model.BYZD4;
        else
            parameters[45].Value = DBNull.Value;


        if (model.BYZD5 != null)
            parameters[46].Value = model.BYZD5;
        else
            parameters[46].Value = DBNull.Value;


        if (model.BYZD6 != null)
            parameters[47].Value = model.BYZD6;
        else
            parameters[47].Value = DBNull.Value;


        if (model.BYZD7 != null)
            parameters[48].Value = model.BYZD7;
        else
            parameters[48].Value = DBNull.Value;

        parameters[49].Value = model.BYZD8;
        parameters[50].Value = model.BYZD9;
        parameters[51].Value = model.BYZD10;
        parameters[52].Value = model.BYZD11;
        parameters[53].Value = model.BYZD12;
        parameters[54].Value = model.BYZD13;

        if (model.BYZD14 != DateTime.MinValue)
            parameters[55].Value = model.BYZD14;
        else
            parameters[55].Value = DBNull.Value;


        if (model.BYZD15 != DateTime.MinValue)
            parameters[56].Value = model.BYZD15;
        else
            parameters[56].Value = DBNull.Value;

        parameters[57].Value = model.AGE;

        if (model.VERSION != null)
            parameters[58].Value = model.VERSION;
        else
            parameters[58].Value = DBNull.Value;


        SqlHelper.RunProcedure(SqlHelper.LocalSqlServer, "sp_V_CUSTOMER_Update", parameters, out rowsAffected);
        return rowsAffected > 0;
    }

    /// <summary>
    /// 删除一条数据
    /// </summary>
    public bool Delete(string DM)
    {
        int rowsAffected;
        SqlParameter[] parameters = {
                    new SqlParameter("@DM", SqlDbType.VarChar,20)};
        parameters[0].Value = DM;

        SqlHelper.RunProcedure(SqlHelper.LocalSqlServer, "sp_V_CUSTOMER_Delete", parameters, out rowsAffected);
        return rowsAffected > 0;
    }

    /// <summary>
    /// 是否存在该记录
    /// </summary>
    public bool Exists(string DM)
    {
        int rowsAffected;
        SqlParameter[] parameters = {
                    new SqlParameter("@DM", SqlDbType.VarChar,20)};
        parameters[0].Value = DM;
        return SqlHelper.RunProcedure(SqlHelper.LocalSqlServer, "sp_V_CUSTOMER_Exists", parameters, out rowsAffected) == 1;
    }

    /// <summary>
    /// 得到一个对象实体
    /// </summary>
    public Model.V_CUSTOMER GetModel(string DM)
    {
        SqlParameter[] parameters = {
                    new SqlParameter("@DM", SqlDbType.VarChar,20)};
        parameters[0].Value = DM;
        DataSet ds = SqlHelper.RunProcedure(SqlHelper.LocalSqlServer, "sp_V_CUSTOMER_GetModel", parameters, "ds");
        if (ds.Tables[0].Rows.Count > 0)
        {
            DataRow r = ds.Tables[0].Rows[0];
            return GetModel(r);
        }
        else
        {
            return null;
        }
    }

    /// <summary>
    /// 获取泛型数据列表
    /// </summary>
    public IList<Model.V_CUSTOMER> GetList()
    {
        SqlParameter[] parameters ={ };
        DataSet ds = SqlHelper.RunProcedure(SqlHelper.LocalSqlServer, "sp_V_CUSTOMER_GetList", parameters, "ds");
        return GetList(ds.Tables[0]);
    }

    /// <summary>
    /// 分页获取泛型数据列表
    /// </summary>
    public IList<Model.V_CUSTOMER> GetList(int pageSize, int pageIndex, string fldSort, bool sort, string strCondition, out int pageCount, out int count)
    {
        string strSql;
        DataSet ds = SqlHelper.PageList(SqlHelper.LocalSqlServer, "[V_CUSTOMER]", null, pageSize, pageIndex, fldSort, sort, strCondition, "DM", false, out pageCount, out count, out strSql);
        return GetList(ds.Tables[0]);
    }
    #endregion

    /// <summary>
    /// 由一行数据得到一个实体
    /// </summary>
    private Model.V_CUSTOMER GetModel(DataRow r)
    {
        Model.V_CUSTOMER model = new Model.V_CUSTOMER();
        model.DM = SqlHelper.GetString(r["DM"]);
        model.GKMC = SqlHelper.GetString(r["GKMC"]);
        model.SEX = SqlHelper.GetString(r["SEX"]);
        model.SR = SqlHelper.GetDateTime(r["SR"]);
        model.BM = SqlHelper.GetString(r["BM"]);
        model.KITHMC = SqlHelper.GetString(r["KITHMC"]);
        model.KITHSEX = SqlHelper.GetString(r["KITHSEX"]);
        model.QYDM = SqlHelper.GetString(r["QYDM"]);
        model.QDDM = SqlHelper.GetString(r["QDDM"]);
        model.CKDM = SqlHelper.GetString(r["CKDM"]);
        model.JDRQ = SqlHelper.GetDateTime(r["JDRQ"]);
        model.XGRQ = SqlHelper.GetDateTime(r["XGRQ"]);
        model.FKBJ = SqlHelper.GetString(r["FKBJ"]);
        model.TKBJ = SqlHelper.GetString(r["TKBJ"]);
        model.XFJE = SqlHelper.GetDecimal(r["XFJE"]);
        model.XFSL = SqlHelper.GetInt(r["XFSL"]);
        model.DQJF = SqlHelper.GetInt(r["DQJF"]);
        model.DZ = SqlHelper.GetString(r["DZ"]);
        model.YB = SqlHelper.GetString(r["YB"]);
        model.SJ = SqlHelper.GetString(r["SJ"]);
        model.DH = SqlHelper.GetString(r["DH"]);
        model.CZ = SqlHelper.GetString(r["CZ"]);
        model.EMAIL = SqlHelper.GetString(r["EMAIL"]);
        model.BZ = SqlHelper.GetString(r["BZ"]);
        model.SZGG = SqlHelper.GetString(r["SZGG"]);
        model.XZGG = SqlHelper.GetString(r["XZGG"]);
        model.COUNTRY = SqlHelper.GetString(r["COUNTRY"]);
        model.DISTRICT = SqlHelper.GetString(r["DISTRICT"]);
        model.CITY = SqlHelper.GetString(r["CITY"]);
        model.EDUCATION = SqlHelper.GetString(r["EDUCATION"]);
        model.OCCUPATION = SqlHelper.GetString(r["OCCUPATION"]);
        model.MARRY = SqlHelper.GetString(r["MARRY"]);
        model.EARNING = SqlHelper.GetString(r["EARNING"]);
        model.WORTH = SqlHelper.GetString(r["WORTH"]);
        model.DUDS = SqlHelper.GetString(r["DUDS"]);
        model.KNOWS = SqlHelper.GetString(r["KNOWS"]);
        model.FJSX1 = SqlHelper.GetString(r["FJSX1"]);
        model.FJSX2 = SqlHelper.GetString(r["FJSX2"]);
        model.FJSX3 = SqlHelper.GetString(r["FJSX3"]);
        model.FJSX4 = SqlHelper.GetString(r["FJSX4"]);
        model.FJSX5 = SqlHelper.GetString(r["FJSX5"]);
        model.FJSX6 = SqlHelper.GetString(r["FJSX6"]);
        model.BYZD1 = SqlHelper.GetString(r["BYZD1"]);
        model.BYZD2 = SqlHelper.GetString(r["BYZD2"]);
        model.BYZD3 = SqlHelper.GetString(r["BYZD3"]);
        model.BYZD4 = SqlHelper.GetString(r["BYZD4"]);
        model.BYZD5 = SqlHelper.GetString(r["BYZD5"]);
        model.BYZD6 = SqlHelper.GetString(r["BYZD6"]);
        model.BYZD7 = SqlHelper.GetString(r["BYZD7"]);
        model.BYZD8 = SqlHelper.GetInt(r["BYZD8"]);
        model.BYZD9 = SqlHelper.GetInt(r["BYZD9"]);
        model.BYZD10 = SqlHelper.GetInt(r["BYZD10"]);
        model.BYZD11 = SqlHelper.GetDecimal(r["BYZD11"]);
        model.BYZD12 = SqlHelper.GetDecimal(r["BYZD12"]);
        model.BYZD13 = SqlHelper.GetDecimal(r["BYZD13"]);
        model.BYZD14 = SqlHelper.GetDateTime(r["BYZD14"]);
        model.BYZD15 = SqlHelper.GetDateTime(r["BYZD15"]);
        model.AGE = SqlHelper.GetInt(r["AGE"]);
        model.VERSION = SqlHelper.GetString(r["VERSION"]);
        return model;
    }

    /// <summary>
    /// 由数据集得到泛型数据列表
    /// </summary>
    public IList<Model.V_CUSTOMER> GetList(DataTable dt)
    {
        List<Model.V_CUSTOMER> l = new List<Model.V_CUSTOMER>();
        foreach (DataRow r in dt.Rows)
        {
            l.Add(GetModel(r));
        }
        return l;
    }
}

